﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Tezzanator.Net.XNAGUI;
namespace OpenST.Tools
{
    class DraggingPencil : BaseTool
    {
        private bool IsDrawing = false;

        public DraggingPencil(Composition comp, Game game)
            : base(comp, game)
        {
            CursorSprite = game.Content.Load<Texture2D>("Tools/PencilTool");
            OpenST.GetComponent<Gui>(game).Cursor = game.Content.Load<Texture2D>("Tools/PencilTool");
        }

        public override void MouseDown(int x, int y, int NoteNumber, string TileType, bool color)
        {
            IsDrawing = true;
            base.MouseDown(x, y, NoteNumber, TileType, color);
        }

        public override void MouseUp(int x, int y, int NoteNumber, string TileType, bool color)
        {
            IsDrawing = false;
            base.MouseUp(x, y, NoteNumber, TileType, color);
        }

        public override void Update(int x, int y, int NoteNumber, string TileType, bool color)
        {
            if (IsDrawing)
            {
                composition.Tiles[x, y] = (Tiles.BaseTile)System.Reflection.Assembly.GetExecutingAssembly().CreateInstance(TileType, false, System.Reflection.BindingFlags.Default, null, new Object[] { game.Content }, null, null);
                composition.Tiles[x, y].color = color;
                composition.Tiles[x, y].NoteNumber = NoteNumber;
                composition.Tiles[x, y].OnCreate(x, y);
            }
            base.Update(x, y, NoteNumber, TileType, color);
        }
    }
}
